# -*- coding: utf-8 -*-
# @Time    : 2022/1/21 11:05
# @Author  : Mr.Ye
# @Email   : a3289748713@163.com
# @File    : configs.py
# @Software: PyCharm
import os


class Config(object):
    # 设置类属性
    # 配置数据库账号密码
    MYSQL_HOST = os.getenv('MYSQL_HOST') or '127.0.0.1'
    MYSQL_USER = os.getenv('MYSQL_USER') or 'user'
    MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD') or 'password'
    MYSQL_DATABASE = os.getenv('MYSQL_DATABASE') or 'test'
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://{root}:{password}@{host}:3306/{name}'.format(root=MYSQL_USER,
                                                                                            password=MYSQL_PASSWORD,
                                                                                            name=MYSQL_DATABASE,
                                                                                            host=MYSQL_HOST)

    # 设置静态方法，做类里其他的无用功
    @staticmethod
    def init_app():
        pass


class ProductionConfig(Config):
    DEBUG = True


class DockerConfig(ProductionConfig):
    DEBUG = False


class DevelopmentConfig(Config):
    DEBUG = True


class TestingConfig(Config):
    TESTING = True


config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,
    'docker': DockerConfig,
    'default': DevelopmentConfig
}
